<template>
  <view @click="onGetAddress">
    <u-row class="location-row">
      <u-icon
        name="map-fill"
        size="50rpx"
        color="success"
      ></u-icon>
      <u-text :text="currentAddress"></u-text>
    </u-row>
  </view>
</template>

<script>
  import { isEmpty } from "lodash";

  export default {
    name: "Address",
    props: {
      /**
       * 当前地理位置精确到街道
       * @type {String}
       */
      currentAddress: {
        type: String,
        default() {
          return "";
        },
        required: true,
      },
    },
    data() {
      return {};
    },
    computed: {
      /**
       * 当branchList为空时，显示加载条
       */
      loading() {
        if (isEmpty(this.currentAddress)) {
          return true;
        }
        return false;
      },
    },
    methods: {
      /**
       * 获得当前地址
       */
      onGetAddress() {
        // TODO 或许可以添加一个dialog让用户自己修改地址
        this.$emit("getAddress");
      },
    },
  };
</script>

<style lang="scss" scoped>
  .location-row {
    display: flex;
    gap: 15rpx;
  }
</style>
